package com.iyundao.io.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.iyundao.io.Service.SignInService;
import com.iyundao.io.model.SignIn;
import com.iyundao.io.tools.ResponseData;
import com.iyundao.io.tools.SignInBatch;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/signin")
public class SignInController {

    @Autowired
    private SignInService signInService;

    @ApiOperation(value="集体签到", notes="集体签到")
    @RequestMapping(value = "/batchsignin", produces = {"application/json;charset=UTF-8"})
    @CrossOrigin
    public ResponseData batchSignIn(@RequestBody String parmas){
        JSONObject object = JSONObject.parseObject(parmas);
        List<Integer> peopleList = (List<Integer>) object.get("peopleList");
        List<String> imageList = (List<String>) object.get("imageList");
        Integer activityid = (Integer) object.get("activityId");
        return signInService.batchSignIn(peopleList, activityid,imageList);
    }

    @ApiOperation(value="个人签到", notes="个人签到")
    @RequestMapping(value = "/addsignin", produces = {"application/json;charset=UTF-8"})
    @CrossOrigin
    public ResponseData signIn(@RequestBody String parmas){
        JSONObject object = JSONObject.parseObject(parmas);
        Integer activityId = (Integer) object.get("activityId");
        return signInService.signIn(activityId);
    }

    @ApiOperation(value="查询未签到人员", notes="查询未签到人员")
    @RequestMapping(value = "/selectnosignin", produces = {"application/json;charset=UTF-8"})
    @CrossOrigin
    public ResponseData selectNoSignIn(@RequestBody String parmas){
        JSONObject object = JSONObject.parseObject(parmas);
        Integer activityId = (Integer) object.get("activityId");
        return signInService.selectNoSignIn(activityId);
    }
}
